<?php
class Auth {
	
	private $stav = false,
	$nick = null,
	$id;
	
	function getStav() {
		return $this->stav;
	}
	
	function setStav($stav = false) {
		$this->stav = $stav;
	}
	
	function getNick() {
		return $this->nick;
	}
	
	function setNick($nick = null) {
		$this->nick = $nick;
	}
	
	function setId($id = null) {
		$this->id = $id;
	}
	
	function getId() {
		return $this->id;
	}
	
	function Login($nick, $password) {
		if($nick == "" or $password == ""){
			return;
		}
		$nick = MySQLData($nick);
		$password = sha1($password);
		$sql = "SELECT id FROM users WHERE nick = '$nick'";
		$ps = mysql_query($sql);
		while ($a = mysql_fetch_row($ps)){
			$id = $a[0];
		}
		$heslo = Users::getPassword($nick);
		if ($heslo == $password) {
			$this->setStav(true);
			$this->setNick($nick);
			$this->setId($id);
		}
	}
	
	function Logout() {
		$this->setStav(false);
		$this->setNick();
		$this->setId();
	}
}
?>